
class ProfitReportController {
    constructor($rootScope,$scope,$state,UserService,AccountService,LotteryService){
        Object.assign(this,{$rootScope,$scope,$state,UserService,AccountService,LotteryService});
        this.$rootScope.currentGroup= this.$state.params.cg;
        this.queryParam = {};
        this.data = [];
        this.init();
    }

    /**
     * 初始化
     */
    init() {
        let self = this;
        let urlParams = self.$state.params;
        //日期时间范围
        laydate.render({
           elem: '#profitReportForm_daterange'
           ,range: '→'
       });

        //执行查询
        self.search(1);
    }



    /**
     * 查询
     */
    search(pageNo){
        let self  = this;
        let param = {};
        //console.log($("#orderListForm_daterange")[0].value);
        let dateRangString = $("#profitReportForm_daterange")[0].value;
        if(dateRangString){
          let pieces =   dateRangString.split('→');
          let startDateStr = pieces[0];
          let endDateStr = pieces[1];
          param.start_date =startDateStr;
          param.end_date =endDateStr;
        }

        param.daterange =  self.queryParam.daterange1;
        param.page_index=pageNo;
        param.page_size=10;

        //console.log(JSON.stringify(param));
        self.AccountService.getProfitReport(param).then(_success).catch(_error);
        function _success(data) {
            // if(data.success==true){
                self.data = data;
            // }
        }
        function _error(reason) {
            console.log(JSON.stringify(reason));
            // layer.alert(reason&&reason.text?reason.text:"对不起操作失败！",{
            //     title:"错误",
            //     icon: 2,
            //     btn:["知道了"],
            //     btn1:function (index,layerro) {
            //         layer.close(index);
            //     }
            // });
        };
    }
}
ProfitReportController.$inject = ["$rootScope","$scope","$state","UserService","AccountService","LotteryService"];

export default ProfitReportController;